import TinyReact from '../src';

const root = document.getElementById('root');

class Alert extends TinyReact.Component {
  constructor(props) {
    super(props);
  }
  componentWillReceiveProps(nextProps) {
    console.log('componentWillReceiveProps');
  }
  componentWillUpdate() {
    console.log('componentWillUpdate');
  }
  componentDidUpdate() {
    console.log('componentDidUpdate');
  }
  componentDidMount() {
    console.log('componentDidMount');
  }
  componentWillUnmount() {
    console.log('componentWillUnmount');
  }
  render(props) {
    return <div>Alert:{this.props.name}</div>;
  }
}

function Demo() {
  return <div>hello</div>;
}

function Heart(props) {
  return (
    <div>
      {props.title}
      &hearts; <Demo></Demo>
    </div>
  );
}

// 更新是不同一个组件
TinyReact.render(<Alert name="haha" />, root);
setTimeout(() => {
  TinyReact.render(<Heart title="xixi" />, root);
}, 2000);
